package com.zr.controller;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.zr.model.Student;
import com.zr.model.Teacher;
import com.zr.model.User;
import com.zr.service.StuentService;

import net.sf.json.JSONObject;

public class SelectStudentByTidController extends HttpServlet {
	StuentService ss=new StuentService();
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doPost(req, resp);
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		String page=req.getParameter("page");
		String rows=req.getParameter("rows");
		String tid=req.getParameter("tid");
		
		int start=(Integer.parseInt(page)-1)*Integer.parseInt(rows);
		resp.setCharacterEncoding("utf8");
		JSONObject jso=ss.findAllStu(start, Integer.parseInt(rows),Integer.parseInt(tid));
		PrintWriter pw=resp.getWriter();
		pw.write(jso.toString());
	}
}
